Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
How to capture "close browser windows" and then update a DataBase item with Django?

Context:

I have a web application in Django. This application is a dashboard where the users can verify and validate the recognition made by an AI of each part of an invoice (prices, taxes...).

The user can manually review this recognition and consequently validate if everything is correct.

Situation:

When a user clicks on the verify button, it will redirect the user to another view. This new view is a Django template with an iframe. This Django view executes a function which updates the status of the item to '31.Verificando usuario' in the DB.

urls.py:

path('verification/<int:id>/', views.VerificationPage, name="fci-verification" )

views.py:

def VerificationPage (request, id):
    invoice= Invoice.objects.get(id=id)
    url= invoice.verification_url
    invoice_id = invoice.id
    status = '31.Verificando usuario'
    message = _('Invoice in web verification')
    try:
        change_invoice_status(invoice_id, status, message)
    except Exception as e:
        capture_exception(e)
    return render(request, "fci_verification.html", {'verification_url': 
                  url,'invoice_id': id})

When this user clicks on "verified" into iframe, I catch this event with window.addEventListener("message", receiveMessage, false); and update to new status.

Problem:

If the user closes the tab or browser, the item status stays as "31.Verificando usuario" and another user cannot review this invoice.

How can I capture a "close windows or tab" event and change the status to the previous status?

RESUME:

  1. I have a dashboard to verify invoices.
  2. When the user clicks on the verify button, the invoice status is updated to "31.Verificando usuario" .
  3. If user close browser without verify the invoice, this invoice stays with wrong status.
  4. I need capture this "close tab/browser" and update to the previous status.
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda